package com.xianzw.mnfun.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import com.xianzw.mnfun.model.domain.ConstellationFortune;
import com.xianzw.mnfun.model.domain.TouTiao;
import com.xianzw.mnfun.repository.ConstellationFortuneRepository;
import com.xianzw.mnfun.service.ConstellationFortuneService;
import com.xianzw.mnfun.utils.DateUtils;

/**
 * 星座运势
 * @author xianzw
 *
 * 2018年9月12日上午10:02:33
 */
@Service
public class ConstellationFortuneServiceImpl implements ConstellationFortuneService{

    @Autowired
    private ConstellationFortuneRepository constellationFortuneRepository;
    
    /**
     * 获取今日星座运势
     */
    @Override
    public List<ConstellationFortune> findByDate() {
	Date date = new Date();
	String dateString = DateUtils.dateToString(date, DateUtils.DEFAULT_DATE_PATTERN);
	
	Sort sort = new Sort(Sort.Direction.ASC, "astroid");
	return constellationFortuneRepository.findByDateLike(dateString+'%',sort);
    }

}
